<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Notices extends CI_Controller {
	
	function index(){
		//获取公告
		$page = intval($this->input->get_post('page'));
		$page = $page ? $page : 1;
		$cdata['where']['nid'] = 18;//22;
		$cdata['page_size']  = 8;
		$cdata['page_start'] = ($page-1)*$cdata['page_size'];
		$cdata['select'] 	= 1;
		$this->load->model('article_model');
		$ret = $this->article_model->get_article_list($cdata);
		//$data['list'] = $list;
		$list = array();
		foreach ($ret['article_list'] as $key => $val){
			$tmpNotice = array();
			$tmpNotice['id'] = $val['id'];
			$tmpNotice['title'] = $val['title'];
			$tmpNotice['ptime'] = date('Y-m-d', $val['ptime']);
			$list[] = $tmpNotice;
		}
		echo json_encode($list);
	}
	
	function content($id){
		$this->load->model('article_model');
		$article = $this->article_model->get_article_obj($id);
		$vdata['article'] = $article;
		$vdata['code'] = 0;
		echo json_encode($vdata);
	}
}